package com.voip.Invite;

import javax.media.MediaLocator;
import javax.media.Time;
import javax.media.protocol.*;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by RXJ on 2018/1/25.
 */
public class InputStreamDataSource extends PullDataSource {

    String contentType;
    InputStream in;

    public InputStreamDataSource (InputStream in, String contentType) {
        this.contentType = contentType;
        this.in = in;
    }
    /* (non-Javadoc)
     * @see javax.media.protocol.PullDataSource#getStreams()
     */
    public PullSourceStream[] getStreams() {
        PullSourceStream [] streams = new PullSourceStream [1];
        InputSourceStream iss = new InputSourceStream(in,
                new FileTypeDescriptor(ContentDescriptor.RAW));
        streams[0] = iss;
        return streams;
    }

    /* (non-Javadoc)
     * @see javax.media.protocol.DataSource#getContentType()
     */
    public String getContentType() {
        return contentType;
    }

    /* (non-Javadoc)
     * @see javax.media.protocol.DataSource#connect()
     */
    public void connect() throws IOException {
    }

    /* (non-Javadoc)
     * @see javax.media.protocol.DataSource#disconnect()
     */
    public void disconnect() {
    }

    /* (non-Javadoc)
     * @see javax.media.protocol.DataSource#start()
     */
    public void start() throws IOException {
    }

    /* (non-Javadoc)
     * @see javax.media.protocol.DataSource#stop()
     */
    public void stop() throws IOException {
    }

    /* (non-Javadoc)
     * @see javax.media.Controls#getControl(java.lang.String)
     */
    public Object getControl(String arg0) {
        return null;
    }

    /* (non-Javadoc)
     * @see javax.media.Controls#getControls()
     */
    public Object[] getControls() {
        return null;
    }

    /* (non-Javadoc)
     * @see javax.media.Duration#getDuration()
     */
    public Time getDuration() {
        return null;
    }


    public MediaLocator getLocator() {
        return null;
    }
}